package thread;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Hua YY
 * Date: 2024-09-19
 * Time: 9:20
 */
class MyTread3 implements Runnable{
    @Override
    public void run() {
        while(true){
            System.out.println("这里是run线程");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
public class TreadDome3 {
    public static void main(String[] args) {
        Runnable runnable = new MyTread3();//相当于借刀杀人了
        Thread t = new Thread(runnable);
        //错误写法Thread t = new MyThread3();
        t.start();
        while(true){
            System.out.println("这里是main函数线程");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }


}
